package com.example.permissionserviceconsumer.service;

import com.myprojects.common.pojo.Resource;
import com.myprojects.common.pojo.Role;
import com.github.pagehelper.PageInfo;
import com.myprojects.common.dto.Msg;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@Component
public class FeignRoleServiceFallback implements FeignRoleService{

    /**
      * 该方法用于分页查询所有的用户信息(非员工)
      */
    @Override
    public Msg selectRolesByPageNum(
            @RequestParam(value = "pn",defaultValue = "1") Integer pageNum){
        Msg msg = Msg.failed();
        List<Role> roleList = new ArrayList();
        Role role = new Role();
        role.setId(-1);
        role.setRole_name("提供者无响应!");
        role.setBrief("提供者无响应!");
        for (int i = 0; i < 10; i++) {
            roleList.add(role);
        }
        PageInfo pageInfo = new PageInfo(roleList);
        msg.setMsg("查询角色接口无响应!");
        msg.addData("pageInfo",pageInfo);
        return msg;
    }

    /**
     * 该方法用于保存角色
     */
    @Override
    public Msg saveRole( Role role){
        Msg msg = Msg.failed();
        msg.setMsg("保存角色接口无响应!");
        return msg;
    }

    /**
     * 该方法用于删除角色
     */
    @Override
    public Msg deleteRole(@RequestParam(value = "id") Integer id){
        Msg msg = Msg.failed();
        msg.setMsg("删除角色接口无响应!");
        return msg;
    }

    /**
     * 该方法用于更新角色
     */
    @Override
    public Msg updateRole(@RequestBody Role role){
        Msg msg = Msg.failed();
        msg.setMsg("更新角色接口无响应!");
        return msg;
    }

    /**
     * 该方法用于分页查询所有的权限信息
     */
    @Override
    public Msg getAllResources(){
        Msg msg = Msg.failed();
        List resourceList = new ArrayList();
        Resource resource = new Resource();
        resource.setId(-1);
        resource.setResource_name("提供者无响应!");
        for (int i = 0; i < 10; i++) {
            resourceList.add(resource);
        }
        msg.setMsg("查询权限接口无响应!");
        msg.addData("resourceList",resourceList);
        return msg;
    }

}
